#include "standalones.h"

wxArrayString SplitString(wxString s, wxString delimiter)
{
    wxArrayString a;

    wxStringTokenizer tox0r(s, delimiter);
    while (tox0r.HasMoreTokens())  a.Add(tox0r.GetNextToken());

    return a;
}


wxString SafeGetLine(wxTextFile &f, unsigned long n)
{
    if(f.GetLineCount() > n) return f.GetLine(n);
    else return wxT("");
}

wxString EscapeURL(wxString s)
{
    // do this one first!! (or you'll replace the rest)
    s.Replace(wxT("\%"), wxT("\%25"));

    // now do the rest
    s.Replace(wxT(" "), wxT("\%20"));
    s.Replace(wxT("#"), wxT("\%23"));
    s.Replace(wxT("$"), wxT("\%24"));
    s.Replace(wxT("&"), wxT("\%26"));
    s.Replace(wxT("/"), wxT("\%2F"));
    s.Replace(wxT(":"), wxT("\%3A"));
    s.Replace(wxT(";"), wxT("\%3B"));
    s.Replace(wxT("<"), wxT("\%3C"));
    s.Replace(wxT("="), wxT("\%3D"));
    s.Replace(wxT(">"), wxT("\%3E"));
    s.Replace(wxT("?"), wxT("\%3F"));
    s.Replace(wxT("@"), wxT("\%40"));
    s.Replace(wxT("["), wxT("\%5B"));
    s.Replace(wxT("\\"), wxT("\%5C"));
    s.Replace(wxT("]"), wxT("\%5D"));
    s.Replace(wxT("^"), wxT("\%5E"));
    s.Replace(wxT("`"), wxT("\%60"));
    s.Replace(wxT("{"), wxT("\%7B"));
    s.Replace(wxT("|"), wxT("\%7C"));
    s.Replace(wxT("}"), wxT("\%7D"));
    s.Replace(wxT("~"), wxT("\%7E"));
    return s;
}







